package scantask.containers.operationStanzas;

import java.util.Set;

import scantask.containers.WeekDate;
import scantask.server.domainLayer.ControllerInterface;
import scantask.server.domainLayer.Exceptions.GetValidDatesException;

public class GetValidDatesStanza extends Stanza {

	private String _userName;
	
	public GetValidDatesStanza(String userName) {
		this._userName = userName;
	}
	
	@Override
	public String perform(ControllerInterface controller) {
		try {
			Set<WeekDate> dates = controller.getValidDates(this._userName);
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending valid dates to " + this._userName);
			return this.parseToXML(dates);
		} catch (GetValidDatesException e) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Sending exception to " + this._userName + " about get valid dates request");
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning(e.getErrorDescription());
			return this.parseToXML(e);
		}
	}

}
